//
//  NewsRequest.h
//  Together
//
//  Created by Wang Shuguang on 12-12-14.
//  Copyright (c) 2012年 Dawn. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "SDWebImageManager.h"
#import "SDImageCache.h"
#import "AFJSONRequestOperation.h"
#import "JSONKit.h"


typedef enum{
    Budejie,
    BudejieMM,
    NetEasyHeadline,
    Qiubai,
    Budejie_Download,
    BudejieMM_Download,
    NetEasyHeadline_Download,
    Qiubai_Download
}RequestNewsType;

@protocol NewsRequestDelegate;

@interface NewsRequest : NSObject<SDWebImageManagerDelegate>{
@private
    NSURL *src;                         // 请求路径
    RequestNewsType newsType;           // 请求类型
    NSInteger imageCount;               // 图片已缓存数量
    NSInteger contentCount;             // 内容已缓存数量
    NSMutableArray *imageArray;         // 待缓存图片地址数组
    NSMutableArray *contentArray;       // 带缓存内容地址数组
    NSDictionary *dataDict;             // 主数据容器
    NSInteger index;                    // 当前请求在队列中的位置
    id delegate;                        // 委托
    
    AFHTTPRequestOperation *operation;
}
@property (nonatomic,retain) NSURL *src;
@property (nonatomic,assign) id<NewsRequestDelegate> delegate;      
@property (nonatomic,retain) NSDictionary *dataDict;
@property (nonatomic,retain) NSString *saveName;                    // 主数据保存文件名
@property (nonatomic) NSInteger index;
@property (nonatomic) RequestNewsType newsType;

+ (id) requestWithURL:(NSURL *)url;
- (void) requestWithNewsType:(RequestNewsType)requestNewsType;
- (void) startRequest;
- (void) cancelRequest;
@end

@protocol NewsRequestDelegate <NSObject>
@optional
-(void) requestFailed:(NewsRequest *)request;
-(void) requestFinished:(NewsRequest *)request withData:(NSDictionary *)dict;
-(void) requestProgress:(float)progress request:(NewsRequest *)request;
@end
